class Solution {
private:
    int arr[1001];
    int brr[1001];
public:
    int findJudge(int n, vector<vector<int>>& trust) {
        for (int i = 0; i < trust.size(); i++) {
            arr[trust[i][0]]++;
            brr[trust[i][1]]++;
        }
        int cnt = 0;
        int index = 0;
        for (int i = 1; i <= n; i++) {
            if (arr[i] == 0 && brr[i] == n - 1) {
                cnt++;
                index = i;
            }
        }
        if (cnt == 1) { return index; }
        else { return -1; }
    }
};